﻿FlyTalk.views.ComposeView = Ext.extend(Ext.form.FormPanel, {

	
    initComponent: function () {
		// back button on toolbar
		this.backButton = new Ext.Button({
			text: 'Back',
			ui: 'back',
			handler: this.backButtonTap,
			scope: this
		});
		
		this.postButton = new Ext.Button({
            text: 'Post',
            ui: 'action',
            handler: this.postButtonTap,
            scope: this
        });
		
		// top tool bar
		this.composeToolbar = new Ext.Toolbar({
			title: 'Compose',
			
			items:[
				this.backButton,
				{ xtype: 'spacer' },
				this.postButton,
			]
			
		});

        this.dockedItems = [this.composeToolbar];

        FlyTalk.views.ComposeView.superclass.initComponent.call(this);
    },	

    backButtonTap: function () {
		this.reset();
        Ext.dispatch({
            controller: FlyTalk.controllers.ftController,
            action: 'toTweetDeck1'
        });
    },
	
	postButtonTap: function () {
		var messageField = Ext.getCmp('message').getValue();
		//var scopeSelect = Ext.getCmp("limit").getValue();
		//alert("post");
		this.reset();
        Ext.dispatch({
            controller: FlyTalk.controllers.formController,
            action: 'postMsg',
			msg: messageField,
			//scope: scopeSelect,
        });
    },
	
	scroll: false,
	/*
    items: [
	{ // serach in
        xtype: 'textfield',
        name: 'search',
		id: 'searchfield',
        label: 'Search',
        required: true
   	},
	{ // search from (scope)
		 xtype: 'selectfield',
		 name: 'scope',
		 id: 'scopeselect',
		 label: 'Search in comments from: ',
		 labelWidth: 300,
		 labelAlign: 'top',
		 style: 'margin-top: 20px',
    	 options: [
       		{text: 'my flight',  value: '@flight'},
       		{text: 'my airline', value: '@airline'},
       		{text: 'my terminal',  value: '@terminal'},
			{text: 'all airport',  value: '@airport'}
    		]
	}]*/
	items: [
	{  // textarea for msg
        xtype: 'textareafield',
		id:'message',
        name: 'title',
        label: 'Message',
		labelWidth: 100,
        required: true
    },/* { // select a tag
        xtype: 'selectfield',
        name: 'tag',
		id: 'limit',
        label: 'Add Tag',
		labelWidth: 100,
		options: [
       		{text: 'my flight',  value: 'first'},
       		{text: 'my airline', value: 'second'},
       		{text: 'my terminal',  value: 'third'},
			{text: 'all airport',  value: 'fourth'}
    	]
	}*/
	]
});

